<!--
 * Created by PhpStorm.
 * User: jackhhy
 * Date: 2019/7/23-16:24
 * Link: https://gitee.com/luckygyl/LuckyAdmin
 * FileName: edit_article.html
 *-->


{include file="public/open_head" /}

<link rel="stylesheet" href="{__FRAME_PATH}css/inputTags.css" >

<div class="ok-body" >

    <div class="layui-fluid" >

        <form class="layui-form" style="margin-top: 30px;">

            <div class="layui-form-item " style=""  >
                <label class="layui-form-label" >所属栏目：</label >
                <div class="layui-input-inline input-custom-width">
                    <select name="navigate_id" lay-search=""  lay-verify="required" lay-verType="tips" lay-reqText="请选择栏目" >
                        <option value="">请选择栏目</option>
                        {volist name="navigate" id="v"}
                        <option value="{$v.id}" {eq name="$info.navigate_id" value="$v.id" } selected {/eq} {eq name="$v.pid" value="0" } disabled {/eq}>├─ {$v.title}</option>
                        {/volist}
                    </select>
                </div >
            </div >

            <div class="layui-form-item " style=""  >
                <label class="layui-form-label" >文章标题：</label >
                <div class="layui-input-block input-custom-width " style="width: 350px;" >
                    <input type="text" name="title" value="{$info.title}" placeholder="请输入文章标题" lay-verify="required" lay-verType="tips" lay-reqText="请输入文章标题" autocomplete="off"  class="layui-input name" >
                </div >
            </div >

            {:token()}

            <input type="hidden" name="id" value="{$info.id}" >
            <div class="layui-form-item ">
                <label class="layui-form-label">缩略图：</label>
                <div class="layui-input-inline" style="width: 350px;">
                    <input name="image_url"    id="LAY_avatarSrc"  readonly placeholder="文章缩略图" value="{$info.image_url}" class="layui-input">
                </div>
                <div class="layui-input-inline layui-btn-container" style="width: auto;">
                    <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                        <i class="layui-icon">&#xe67c;</i>选择图片
                    </button>
                  <a class="layui-btn layui-btn-warm" id="avartatPreview">素材库选择</a >
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否推荐：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="radio" name="is_recommend" value="1" title="是" {eq name="$info.is_recommend" value="1" } checked {/eq}>
                    <input type="radio" name="is_recommend" value="0" title="否"  {eq name="$info.is_recommend" value="1" } checked {/eq}>
                </div>
                <div class="layui-form-mid layui-word-aux">用于前台推荐调用</div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">是否置顶：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="radio" name="is_top" value="1" title="是"   {eq name="$info.is_top" value="1" } checked {/eq} >
                    <input type="radio" name="is_top" value="0" title="否"  {eq name="$info.is_top" value="0" } checked {/eq}>
                </div>
                <div class="layui-form-mid layui-word-aux">用于前台置顶调用</div>
            </div>


            <div class="layui-form-item " >
                <label class="layui-form-label" >关键词：</label >
                <div class="layui-input-inline input-custom-width " style="width: 350px;" >
                    <input type="text" name="keywords" value="{$info.keywords}" placeholder="关键词" lay-verify="required" lay-verType="tips" lay-reqText="关键词" autocomplete="off"  class="layui-input name" >
                </div >
                <div class="layui-form-mid layui-word-aux">关键词以英文逗号隔开</div>
            </div >

            <div class="layui-form-item "  >
                <label class="layui-form-label" >摘要：</label >
                <div class="layui-input-inline input-custom-width " style="width: 450px;" >
                    <textarea class="layui-textarea" autocomplete="off" name="description" placeholder="请输入摘要">{$info.description}</textarea>
                </div >
            </div >

            <div class="layui-form-item " >
                <label class="layui-form-label" >点击量：</label >
                <div class="layui-input-inline input-custom-width " style="width: 350px;" >
                    <input type="hits" min="0" name="name" value="{$info.hits}" placeholder="关键词" lay-verify="required" lay-verType="tips" lay-reqText="关键词" autocomplete="off"  class="layui-input" >
                </div >
                <div class="layui-form-mid layui-word-aux">文章的点击数量</div>
            </div >

            <div class="layui-form-item "  >
                <label class="layui-form-label" >文章类型：</label >
                <div class="layui-input-inline input-custom-width "  >
                    <select name="source" >
                        <option value="原创" {eq name="$info.source" value="原创" } selected {/eq}>原创</option >
                        <option value="转载"  {eq name="$info.source" value="转载" } selected {/eq}>转载</option >
                    </select >
                </div >
                <label class="layui-form-label" >作者：</label >
                <div class="layui-input-inline input-custom-width "  >
                    <input type="text" name="author" value="{$info.author}" placeholder="文章作者" lay-verify="required" lay-verType="tips" lay-reqText="文章作者" autocomplete="off"  class="layui-input " >
                </div >

            </div >


            <div class="layui-form-item ">
                <label class="layui-form-label">文章内容：</label>
                <div class="layui-input-block">
                    <textarea name="content"  placeholder="文章内容" lay-verify="content1" id="LAY_demo1"  >{$info.content}</textarea>
                </div>
            </div>


            <div class="layui-form-item">

                <label class="layui-form-label">文章地址：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="text" class="layui-input" value="{$info.url}" >
                </div>

                <label class="layui-form-label">添加时间：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="text" class="layui-input" value="{$info.time_formt}">
                </div>
                <div class="layui-form-mid layui-word-aux">文章远程图片本地化</div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否显示：</label>
                <div class="layui-input-inline input-custom-width ">
                    <select name="status" >
                        <option value="1" {eq name="$info.status" value="1" } selected {/eq}>显示</option>
                        <option value="2" {eq name="$info.status" value="2" } selected {/eq}>不显示</option>
                        <option value="3" {eq name="$info.status" value="3" } selected {/eq}>草稿文章</option>
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">是否在首页展示文章</div>

                <label class="layui-form-label">内容首图：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="radio" name="pic" value="1" title="是"  >
                    <input type="radio" name="pic" value="0" title="否" checked>
                </div>
                <div class="layui-form-mid layui-word-aux">提取内容第一张图片为缩略图</div>
            </div>

            <div class="layui-form-item">

                <label class="layui-form-label">保存为草稿：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="radio" name="cao" value="1" title="是" >
                    <input type="radio" name="cao" value="0" title="否"  checked>
                </div>
                <div class="layui-form-mid layui-word-aux">文章保存为草稿不发布</div>

                <label class="layui-form-label">图片本地化：</label>
                <div class="layui-input-inline input-custom-width">
                    <input type="radio" name="img" value="1" title="是" >
                    <input type="radio" name="img" value="0" title="否"  checked>
                </div>
                <div class="layui-form-mid layui-word-aux">文章远程图片本地化</div>
            </div>

            <div class="layui-form-item layui-layout-admin " style="width: 100%">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0px;text-align: center;">
                        <button class="layui-btn" lay-submit="" lay-filter="add">立即保存</button>

                    </div>
                </div>
            </div>


        </form>

    </div >


</div >

<!-- 配置文件 -->
<script type="text/javascript" src="{__PLUG_PATH}ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="{__PLUG_PATH}ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('LAY_demo1', {
        autoHeightEnabled:false,
        initialFrameHeight:420,
        zIndex : 0,
    });
</script>

<script >

    layui.config({
        base: '{__FRAME_PATH}js/',
    }).extend({
        inputTags: 'inputTags'
    });

    layui.use(['element', 'form', 'jquery', 'upload','inputTags','layedit'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var upload = layui.upload;

        $('#LAY_avatarSrc').hover(function(){
            var img = "<img class='img_msg' src='"+$(this).val()+"' style='width:100%;max-height: 600px;' />";
            img_show = layer.tips(img, this,{
                tips:[2, 'rgba(41,41,41,.0)']
                ,area: ['12%']
            });
        },function(){
            layer.close(img_show);
        });


        //图片上传
        upload.render({
            elem:'#LAY_avatarUpload'
            ,url: "{:url('admin/common/UpThumbImg')}" //
            ,accept: 'images' //
            ,acceptMime: 'image/*'
            ,size: 1024*9
            ,data:{width:700,height:600}
            ,before:function (res) {
                loading = layer.load(2, {
                    shade: [0.2, '#000'] //0.2透明度的白色背景
                });
            }
            ,done: function(data){
                layer.close(loading);
                if (data.code==1){
                    layer.msg(data.msg, {icon: 1, time: 1000},function () {1
                        $("#LAY_avatarSrc").val(data.path);
                    });
                } else {
                    layer.msg(data.msg, {icon: 5, time: 1000});
                }
            }
            ,error:function (red) {
                layer.close(loading);
                layer.msg("网络错误", {icon: 5, time: 1500});
            }
        });

        /**
         * 提交表单数据
         */
        form.on('submit(add)', function (data) {
            FormSubmit("{:url('article/EditArticle')}", data.field, "table_id", 1);
            return false;
        });


        // 弹窗选择
        $('#avartatPreview').click(function () {
            layer.open({
                title:"选择素材",
                type: 2,
                area: ["50%", "80%"],
                offset:'auto',
                maxmin : true,
                skin:'layui-layer-molv',
                shade: 0.5,
                content: "{:url('article/get_images')}",
                success:function(){
                    setTimeout(function(){
                        layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3,time:1000
                        });
                    },500)
                },
            });
            return false;
        });

    })
</script >


</body>
</html>